const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    type:"",
    lawyerId:""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function ({type}) {
    this.setData({type})
    if(type == "office"){
      wx.setNavigationBarTitle({
        title: '律所管理'
      })
    }else{
      wx.setNavigationBarTitle({
        title: '律师管理'
      })
    }
    this.getData()
    
  },
  link(){
    if(this.data.type == 'office'){
      wx.navigateTo({
        url: '/packageI/lawyerPlatform/share/share?order_type=office',
      })
    }else{
      wx.navigateTo({
        url: '/packageI/lawyerPlatform/share/share?order_type=lawyer',
      })
    }
  },
  mseeage(){
    if(this.data.type == 'office'){
      wx.navigateTo({
        url: '/packageI/lawyerPlatform/message/message?lf_id='+this.data.lawyerId,
      })
    }else{
      wx.navigateTo({
        url: '/packageI/lawyerPlatform/chat/chat?message_type=2&l_id='+this.data.lawyerId,
      })
    }
  },
  order(){
    if(this.data.type == 'office'){
      wx.navigateTo({
        url: '/packageI/lawyerPlatform/order/order?order_type=office',
      })
    }else{
      wx.navigateTo({
        url: '/packageI/lawyerPlatform/order/order?order_type=lawyer',
      })
    }
  },
  lawyerServe(){
    wx.navigateTo({
      url: `/packageI/lawyerPlatform/lawyerManage/lawyerManage?id=${this.data.lawyerId}`
    })
  },
  lawyerManage(){
    wx.navigateTo({
      url: `/packageI/lawyerPlatform/officeManage/officeManage?lawyerId=${this.data.lawyerId}`,
    })
  },
  getData(){
      if(this.data.type == "office"){
        app._getNetWork({
          url:app.getNetAddresss("plugin.lawyer-platform.frontend.controllers.lawyer-firm.index"),
          success:(res)=>{
            if(res.data.result == 1){
              this.setData({
               name:res.data.data.lawyer_firm.name,
               lawyerId:res.data.data.lawyer_firm.id,
               logo:res.data.data.lawyer_firm.logo_image
              })
            }
          }
        })
      }else{
        app._getNetWork({
          url:app.getNetAddresss("plugin.lawyer-platform.frontend.controllers.lawyer.index"),
          success:(res)=>{
            if(res.data.result == 1){
              this.setData({
               name:res.data.data.lawyer.name,
               lawyerId:res.data.data.lawyer.id,
               logo:res.data.data.lawyer.avatar_image
              })
            }
          }
        })
      }

  },
  handle(){
      wx.navigateTo({
        url: '/packageI/lawyerPlatform/info/info?type='+this.data.type+'detail',
      })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})